﻿using System.Windows.Forms;
using NoNameGoServer.Client.Commands;

namespace NoNameGoServer.Client.Gui {
    public partial class BoardForm : Form {
        private NNGSClient _client;
        private int _matchNumber;
        private int _boardSize;
        private StoneColor _opponentColor;

        public BoardForm() {
            InitializeComponent();
            _board.IntersectionClicked += _board_IntersectionClicked;
        }

        void _board_IntersectionClicked(GoBoardUserControl sender, char letter, int number) {
            if (_client != null) {
                _client.EnqueueCommand(new PlayCommand(letter, number + 1));
            }
        }

        public void StartGame(NNGSClient client, int matchNumber, int boardSize, StoneColor opponentColor) {
            _client = client;
            _matchNumber = matchNumber;
            _boardSize = boardSize;
            _board.BoardSize = boardSize;
            _opponentColor = opponentColor;
        }

        public void MoveMade(char letter, int number, StoneColor color) {
            _board.SetIntersection(letter, number, color);
        }

        public void CaptureMade(char letter, int number) {
            _board.SetIntersection(letter, number, null);
        }
    }
}
